package com.aaa.charge.api.ChargeLiat;

import com.aaa.charge.feign.DateFegin;
import com.aaa.charge.service.OrderChargeService;
import com.aaa.charge.vo.OrderChargeVo;
import com.aaa.entity.DictData;
import com.aaa.entity.OrderCharge;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author pzs
 * @date 2023/3/24 11:22
 * @description ApiChargeController
 */
@RestController
@RequestMapping("charge/api/orderCharge")
public class ApiChargeController {
    @Autowired
    private OrderChargeService orderChargeService;
    @Resource
    private DateFegin dateFegin;

    /**
     * 收费列表
     * 查询表格收费内容
     */
    @PostMapping("queryCharge/{currentPage}/{pageSize}")
    public Result<IPage<OrderCharge>> queryCharge(
            @PathVariable Integer currentPage,
            @PathVariable Integer pageSize,
            @RequestBody OrderChargeVo orderChargeVo
    ){
        return orderChargeService.findAllCharge(currentPage,pageSize,orderChargeVo);
    }

    //现金支付修改状态
    @GetMapping("payOrder/{orderId}")
    public Result<Integer> payOrder(@PathVariable String orderId){
        return orderChargeService.upByOrderId(orderId);
    }

    //微信支付
    @PostMapping("payOrderZfb/{orderId}")
    public Result payOrderZfb(@PathVariable String orderId)  {
        return orderChargeService.selectAll(orderId) ;
    }

    @PostMapping("queryPayStatus/{orderId}")
    public Result queryPayStatus(@PathVariable String orderId){
        return orderChargeService.queryPayStatus(orderId) ;
    }


    //状态。类型。。。
    @GetMapping("getByType/{type}")
    public Result<List<DictData>> getByType(@PathVariable String type){
        Result<List<DictData>> list = dateFegin.list(type);
        return list;
    }
}
